home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / SWITCH.C < prev    next >
Text File  |  1989-12-30  |  964b  |  27 lines

  1. main()
  2. {
  3. int truck;
  4.  
  5.    for (truck = 3;truck < 13;truck = truck + 1) {
  6.  
  7.       switch (truck) {
  8.          case 3  : printf("The value is three\n");
  9.                    break;
  10.          case 4  : printf("The value is four\n");
  11.                    break;
  12.          case 5  :
  13.          case 6  :
  14.          case 7  :
  15.          case 8  : printf("The value is between 5 and 8\n");
  16.                    break;
  17.          case 11 : printf("The value is eleven\n");
  18.                    break;
  19.          default : printf("It is one of the undefined values\n");
  20.                    break;
  21.       exit();    /* <-- with this in, it will exit if it gets this far. 
  22.                This is often seen with case statements in IF ERR ==
  23.                type statements.                                 */
  24.       } /* end of switch */
  25.  
  26.    } /* end of for loop */
  27. }